'''
Author: your name
Date: 2021-03-23 09:41:58
LastEditTime: 2021-04-02 09:33:21
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: /tinyms/tinyms-api/apps/auth/census/views.py
'''
from flask import render_template,request
from . import auth_census
from .service import CensusService
from .organDto import organDto
from apps.utils import auty

import json

'''
统计用户数、机构数、日志数
'''
@auth_census.route('/count',methods=['GET','POST'])
@auty.login_required #必须登录的装饰器校验
def count():
    #TODO 查询用户、机构、日志总数
    total = {'userTotal':'100','organTotal':'50','logsTotal':'10000'}
    data = {
        'msg':'success',
        'code':0,
        'data':total
    }
    return json.dumps(data,ensure_ascii=False)
    # return data

'''
统计机构
'''
@auth_census.route('/census_organ',methods=['GET','POST'])
@auty.login_required #必须登录的装饰器校验
def census_organ():
    lis = []
    res = CensusService.census_organ()
    data_dict = organDto.to_dict(res)
    data = {
        'msg':'success',
        'code':0,
        'data':data_dict
    }
    return json.dumps(data,ensure_ascii=False)